package com.zcy.thymeleaf.controller;

import com.alibaba.fastjson.JSONObject;
import com.zcy.thymeleaf.config.UserMangerContants;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * Created by sue on 2019/3/6.
 */
@Controller
@Log4j2
public class UserController {

    @Resource
    UserMangerContants userMangerContants;

    @RequestMapping("/getUser")
    @ResponseBody
    public JSONObject getUser(HttpServletRequest request, HttpServletResponse response){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code","0000");
        jsonObject.put("msg","success");
        return jsonObject;
    }

    @RequestMapping("/login")
    public String login(HttpServletRequest request, HttpServletResponse response, Map<String,Object> model){
        model.put("username",userMangerContants.getUsername());
        return "login";
    }
}
